<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //延时函数版本2
        function delay(duration,n){
            return new Promise((reject)=>{
                setTimeout(()=>{
                    console.log(n)  //打印数据
                    reject('Ok')
                },duration)
            })
        }

        // delay(2000,1).then(()=>{
        //     // console.log(msg)
        //     delay(1000,1).then(()=>{
        //         delay(1000,2).then(()=>{
        //             delay(1000,3)
        //         })
        //     })
        // })
        delay(2000,1).then(()=>{
            return delay(1000,2)
        }).then(msg=>{console.log(msg)})
    </script>
</body>
</html>